import multiprocessing
import os
import time

def dance(num):
    if num < 0: num = 0
    # 获取当前进程编号
    print("跳舞进程id：",os.getpid())
    print("跳舞进程父进程编号：",os.getppid())
    print("跳舞当前进程：",multiprocessing.current_process())
    for x in range(num):
        print("我跳舞啦,%d",x)
        time.sleep(0.2)

def sing(num):
    if num < 0:num=0
    # 获取当前进程编号
    print("唱歌进程id：", os.getpid())
    print("唱歌进程父进程编号：",os.getppid())
    print("唱歌当前进程：", multiprocessing.current_process())
    for i in range(num):
        print("我唱歌啦,%d",i)
        time.sleep(0.2)

if __name__ == '__main__':
    # 获取主进程编号
    print("主进程id：",os.getpid())
    # 获取当前进程
    print("主进程当前进程：",multiprocessing.current_process())
    # 创建跳舞子进程
    dance_process = multiprocessing.Process(target=dance,args=(5,))
    # 创建唱歌子进程
    sing_process = multiprocessing.Process(target=sing,kwargs={'num':4})
    # 启动进程任务
    dance_process.start()
    sing_process.start()